<html>
<head><meta charset="utf-8"><title>context sharing #134 · t-compiler/wg-polonius · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/index.html">t-compiler/wg-polonius</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html">context sharing #134</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="177991977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/177991977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#177991977">(Oct 12 2019 at 14:49)</a>:</h4>
<p>Here's a proposal for solving some of the duplication problems, by adding a context shared by the components of the pipeline <a href="https://github.com/rust-lang/polonius/pull/134" target="_blank" title="https://github.com/rust-lang/polonius/pull/134">https://github.com/rust-lang/polonius/pull/134</a></p>



<a name="177991984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/177991984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#177991984">(Oct 12 2019 at 14:49)</a>:</h4>
<p>While it also allowed me to remove some cloning here and there, it mostly avoids computing initialization and liveness twice in the worst case of using the <code>Hybrid</code> variant with potential errors found during the pre-pass.</p>



<a name="177992034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/177992034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#177992034">(Oct 12 2019 at 14:50)</a>:</h4>
<p>It also helps pave the way to using these potential errors to heavily prune the data the following variant uses (and which we have prototyped and know is a big optimization boost, but can't open a PR right now as it could hinder the illegal subset relations errors work)</p>



<a name="177992039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/177992039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#177992039">(Oct 12 2019 at 14:50)</a>:</h4>
<p>let me know what you think :)</p>



<a name="178023501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178023501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178023501">(Oct 13 2019 at 06:18)</a>:</h4>
<p>I’ll look more into it when I have time but COOL</p>



<a name="178023512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178023512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178023512">(Oct 13 2019 at 06:19)</a>:</h4>
<p>Also, about the leapjoins to joins: I thought leapjoins were an optimised form?!</p>



<a name="178031755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178031755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178031755">(Oct 13 2019 at 10:10)</a>:</h4>
<p>(when joining more than one predicate yeah. if you have only two, it's good to try both but regular joins should just do less work in that case — and if the relations happen to have the same key, you wouldn't even save an index, which is the other factor to take into account: sometimes a regular join + the index maintenance it'd require is more costly on bigger relations than a leapjoin on two relations)</p>



<a name="178043351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178043351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178043351">(Oct 13 2019 at 15:55)</a>:</h4>
<p>Ok so my intuition wasn’t entirely off</p>



<a name="178047638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178047638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178047638">(Oct 13 2019 at 17:48)</a>:</h4>
<p>yes, and in this case it doesn't matter much, a difference of 1% (while I remember once trying a leapjoin in LocationInsensitive where it was a 7% pessimization)</p>



<a name="178095877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178095877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178095877">(Oct 14 2019 at 11:48)</a>:</h4>
<p><span class="user-mention" data-user-id="204115">@Albin Stjerna</span> I've pushed the latest changes: stop using allfacts altogether, and divide it in different contexts for each step (which also allowed cleaning up the signatures of initialization/liveness). No step can use another step's data, or overwrite it, etc.</p>



<a name="178096345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178096345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178096345">(Oct 14 2019 at 11:57)</a>:</h4>
<p>Nice! I'll have a look. :)</p>



<a name="178097071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097071">(Oct 14 2019 at 12:09)</a>:</h4>
<p><span class="user-mention" data-user-id="204115">@Albin Stjerna</span> we can't remove the clones without rustc giving us ownership of all_facts</p>



<a name="178097088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097088">(Oct 14 2019 at 12:09)</a>:</h4>
<p>Aah ok</p>



<a name="178097098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097098">(Oct 14 2019 at 12:09)</a>:</h4>
<p>some maybe, but not all</p>



<a name="178097182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097182">(Oct 14 2019 at 12:10)</a>:</h4>
<p>Is this recent? I remember moving out some stuff and that worked fine</p>



<a name="178097188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097188">(Oct 14 2019 at 12:10)</a>:</h4>
<p>But ok I see</p>



<a name="178097189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097189">(Oct 14 2019 at 12:10)</a>:</h4>
<p>nope, since always</p>



<a name="178097193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097193">(Oct 14 2019 at 12:10)</a>:</h4>
<p>you moved them out of the initial allfacts clone</p>



<a name="178097195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097195">(Oct 14 2019 at 12:10)</a>:</h4>
<p>Aaaaah ok I see</p>



<a name="178097214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097214">(Oct 14 2019 at 12:11)</a>:</h4>
<p>That explains it</p>



<a name="178097215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097215">(Oct 14 2019 at 12:11)</a>:</h4>
<p>compute cloned it before passing it to the variants</p>



<a name="178097233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097233">(Oct 14 2019 at 12:11)</a>:</h4>
<p>this is still done, but piecewise for each step context</p>



<a name="178097408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097408">(Oct 14 2019 at 12:14)</a>:</h4>
<p>we may take care of that at the same time as updating rustc to the T: FactTypes API, if we indeed plan to go on with that</p>



<a name="178097644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/context%20sharing%20%23134/near/178097644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/context.20sharing.20.23134.html#178097644">(Oct 14 2019 at 12:18)</a>:</h4>
<p>(btw all the data is Copy/Clone so we could technically "remove the clones" but that wouldn't change much here: we'll want to remove the allocations)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>